import datetime

# 全局变量定义余额
balance = 1000
# 日志存储
account_log = []

# 定义存款函数
def deposit(amount):
    global balance
    balance += amount
    write_log(amount, "存款")

# 定义取款函数
def withdrawal(amount):
    global balance
    if amount > balance:
        print("余额不足")
    else:
        balance -= amount
        write_log(amount, "取款")

# 写入交易日志
def write_log(amount,type):
    now = datetime.datetime.now()
    create_time = now.strftime("%Y-%m-%d %H:%M:%S")
    data = [create_time,type,amount,balance]
    account_log.append(data)

# 读取日志
def print_log():
    print(account_log)

# 显示菜单
def show_menu():
    menu = """
操作菜单：
0：退出
1：存款
2：取款
3：打印交易信息
    """
    print(menu)


while True:
    show_menu()
    operator = int(input("请根据菜单编号输入："))
    if operator == 0:
        print("您已经退出系统")
        break
    elif operator == 1:
        print("存款")
        amount = float(input("请输入存款金额："))
        deposit(amount)
        print(f"当前余额为：{balance}")

    elif operator == 2:
        print("取款")
        amount = float(input("请输入取款金额："))
        withdrawal(amount)
        print(f"当前余额为：{balance}")
    elif operator == 3:
        print("查看记录")
        print_log()
    else:
        print("输入有误！")